﻿using AccompanyCabinet.Helper;
using AccompanyCabinet.Model;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;

namespace AccompanyCabinet.Admin
{
    public partial class SetCost : Form
    {
        public SetCost()
        {
            InitializeComponent();
        }



        private void SetCost_Load(object sender, EventArgs e)
        {
            if (HttpHelper.deviceInfoModel.Type == "One")
            {
                if (HttpHelper.dBoxLists[0].TypeNo == "Big") {
                    mid_panel.Visible = false;
                    small_panel.Visible = false;
                    big_panel.Location =new Point(384, 281);
                    #region Big
                    if (HttpHelper.costDetailList[0].Duration == 0)
                    {
                        txt_Btime1.Text = "";
                        txt_bcost1.Text = "";
                    }
                    else
                    {
                        txt_Btime1.Text = HttpHelper.costDetailList[0].Duration.ToString();
                        txt_bcost1.Text = HttpHelper.costDetailList[0].Price.ToString();
                    }
                    if (HttpHelper.costDetailList[1].Duration == 0)
                    {
                        txt_Btime2.Text = "";
                        txt_bcost2.Text = "";
                    }
                    else
                    {
                        txt_Btime2.Text = HttpHelper.costDetailList[1].Duration.ToString();
                        txt_bcost2.Text = HttpHelper.costDetailList[1].Price.ToString();
                    }
                    if (HttpHelper.costDetailList[2].Duration == 0)
                    {
                        txt_Btime3.Text = "";
                        txt_bcost3.Text = "";
                    }
                    else
                    {
                        txt_Btime3.Text = HttpHelper.costDetailList[2].Duration.ToString();
                        txt_bcost3.Text = HttpHelper.costDetailList[2].Price.ToString();
                    }
                    if(HttpHelper.costDetailList[3].Duration==0)
                    {
                        txt_Btime4.Text = "";
                        txt_bcost4.Text = "";
                    }
                    else
                    {
                        txt_Btime4.Text = HttpHelper.costDetailList[3].Duration.ToString();
                        txt_bcost4.Text = HttpHelper.costDetailList[3].Price.ToString();
                    }
                    if (HttpHelper.costDetailList[4].Duration == 0)
                    {
                        txt_cBtime.Text = "";
                        txt_cbcost.Text = "";
                    }
                    else
                    {
                        txt_cBtime.Text = HttpHelper.costDetailList[4].Duration.ToString();
                        txt_cbcost.Text = HttpHelper.costDetailList[4].Price.ToString();
                    }
                    #endregion
                }
                if (HttpHelper.dBoxLists[0].TypeNo == "Mid")
                {
                    big_panel.Visible = false;
                    small_panel.Visible = false;
                    mid_panel.Location= new Point(384, 281);
                    #region Mid
                    if (HttpHelper.costDetailList[0].Duration == 0)
                    {
                        txt_mtime1.Text = "";
                        txt_mcost1.Text = "";
                    }
                    else
                    {
                        txt_mtime1.Text = HttpHelper.costDetailList[0].Duration.ToString();
                        txt_mcost1.Text = HttpHelper.costDetailList[0].Price.ToString();
                    }
                    if (HttpHelper.costDetailList[1].Duration == 0)
                    {
                        txt_mtime2.Text = "";
                        txt_mcost2.Text = "";
                    }
                    else
                    {
                        txt_mtime2.Text = HttpHelper.costDetailList[1].Duration.ToString();
                        txt_mcost2.Text = HttpHelper.costDetailList[1].Price.ToString();
                    }
                    if (HttpHelper.costDetailList[2].Duration == 0)
                    {
                        txt_mtime3.Text = "";
                        txt_mcost3.Text = "";
                    }
                    else
                    {
                        txt_mtime3.Text = HttpHelper.costDetailList[2].Duration.ToString();
                        txt_mcost3.Text = HttpHelper.costDetailList[2].Price.ToString();
                    }
                    if (HttpHelper.costDetailList[3].Duration == 0)
                    {
                        txt_mtime4.Text = "";
                        txt_mcost4.Text = "";
                    }
                    else
                    {
                        txt_mtime4.Text = HttpHelper.costDetailList[3].Duration.ToString();
                        txt_mcost4.Text = HttpHelper.costDetailList[3].Price.ToString();
                    }
                    if (HttpHelper.costDetailList[4].Duration == 0)
                    {
                        txt_cmtime.Text = "";
                        txt_cmcost.Text = "";
                    }
                    else
                    {
                        txt_cmtime.Text = HttpHelper.costDetailList[4].Duration.ToString();
                        txt_cmcost.Text = HttpHelper.costDetailList[4].Price.ToString();
                    }    
                    #endregion
                }
                if (HttpHelper.dBoxLists[0].TypeNo == "Small")
                {
                    mid_panel.Visible = false;
                    big_panel.Visible = false;
                    small_panel.Location = new Point(384, 281);
                    #region Small
                    if (HttpHelper.costDetailList[0].Duration == 0)
                    {
                        txt_stime1.Text = "";
                        txt_scost1.Text = "";
                    }
                    else
                    {
                        txt_stime1.Text = HttpHelper.costDetailList[0].Duration.ToString();
                        txt_scost1.Text = HttpHelper.costDetailList[0].Price.ToString();
                    }
                    if (HttpHelper.costDetailList[1].Duration == 0)
                    {
                        txt_stime2.Text = "";
                        txt_scost2.Text = "";
                    }
                    else
                    {
                        txt_stime2.Text = HttpHelper.costDetailList[1].Duration.ToString();
                        txt_scost2.Text = HttpHelper.costDetailList[1].Price.ToString();
                    }
                    if (HttpHelper.costDetailList[2].Duration == 0)
                    {
                        txt_stime3.Text = "";
                        txt_scost3.Text = "";
                    }
                    else
                    {
                        txt_stime3.Text = HttpHelper.costDetailList[2].Duration.ToString();
                        txt_scost3.Text = HttpHelper.costDetailList[2].Price.ToString();
                    }
                    if (HttpHelper.costDetailList[3].Duration == 0)
                    {
                        txt_stime4.Text = "";
                        txt_scost4.Text = "";
                    }
                    else
                    {
                        txt_stime4.Text = HttpHelper.costDetailList[3].Duration.ToString();
                        txt_scost4.Text = HttpHelper.costDetailList[3].Price.ToString();
                    }
                    if (HttpHelper.costDetailList[4].Duration == 0)
                    {
                        txt_cstime.Text = "";
                        txt_cscost.Text = "";
                    }
                    else
                    {
                        txt_cstime.Text = HttpHelper.costDetailList[4].Duration.ToString();
                        txt_cscost.Text = HttpHelper.costDetailList[4].Price.ToString();
                    } 
                    #endregion
                }
            }
            if(HttpHelper.deviceInfoModel.Type == "Two")
            {
                mid_panel.Visible = false;
                big_panel.Location = new Point(373, 167);
                small_panel.Location = new Point(373, 509);
                #region Big
                if (HttpHelper.costDetailList[0].Duration == 0)
                {
                    txt_Btime1.Text = "";
                    txt_bcost1.Text = "";
                }
                else
                {
                    txt_Btime1.Text = HttpHelper.costDetailList[0].Duration.ToString();
                    txt_bcost1.Text = HttpHelper.costDetailList[0].Price.ToString();
                }
                if (HttpHelper.costDetailList[1].Duration == 0)
                {
                    txt_Btime2.Text = "";
                    txt_bcost2.Text = "";
                }
                else
                {
                    txt_Btime2.Text = HttpHelper.costDetailList[1].Duration.ToString();
                    txt_bcost2.Text = HttpHelper.costDetailList[1].Price.ToString();
                }
                if (HttpHelper.costDetailList[2].Duration == 0)
                {
                    txt_Btime3.Text = "";
                    txt_bcost3.Text = "";
                }
                else
                {
                    txt_Btime3.Text = HttpHelper.costDetailList[2].Duration.ToString();
                    txt_bcost3.Text = HttpHelper.costDetailList[2].Price.ToString();
                }
                if (HttpHelper.costDetailList[3].Duration == 0)
                {
                    txt_Btime4.Text = "";
                    txt_bcost4.Text = "";
                }
                else
                {
                    txt_Btime4.Text = HttpHelper.costDetailList[3].Duration.ToString();
                    txt_bcost4.Text = HttpHelper.costDetailList[3].Price.ToString();
                }
                if (HttpHelper.costDetailList[4].Duration == 0)
                {
                    txt_cBtime.Text = "";
                    txt_cbcost.Text = "";
                }
                else
                {
                    txt_cBtime.Text = HttpHelper.costDetailList[4].Duration.ToString();
                    txt_cbcost.Text = HttpHelper.costDetailList[4].Price.ToString();
                }
                #endregion

                #region Small
                if (HttpHelper.costDetailList[5].Duration == 0)
                {
                    txt_stime1.Text = "";
                    txt_scost1.Text = "";
                }
                else
                {
                    txt_stime1.Text = HttpHelper.costDetailList[5].Duration.ToString();
                    txt_scost1.Text = HttpHelper.costDetailList[5].Price.ToString();
                }
                if (HttpHelper.costDetailList[6].Duration == 0)
                {
                    txt_stime2.Text = "";
                    txt_scost2.Text = "";
                }
                else
                {
                    txt_stime2.Text = HttpHelper.costDetailList[6].Duration.ToString();
                    txt_scost2.Text = HttpHelper.costDetailList[6].Price.ToString();
                }
                if (HttpHelper.costDetailList[7].Duration == 0)
                {
                    txt_stime3.Text = "";
                    txt_scost3.Text = "";
                }
                else
                {
                    txt_stime3.Text = HttpHelper.costDetailList[7].Duration.ToString();
                    txt_scost3.Text = HttpHelper.costDetailList[7].Price.ToString();
                }
                if (HttpHelper.costDetailList[8].Duration == 0)
                {
                    txt_stime4.Text = "";
                    txt_scost4.Text = "";
                }
                else
                {
                    txt_stime4.Text = HttpHelper.costDetailList[8].Duration.ToString();
                    txt_scost4.Text = HttpHelper.costDetailList[8].Price.ToString();
                }
                if (HttpHelper.costDetailList[9].Duration == 0)
                {
                    txt_cstime.Text = "";
                    txt_cscost.Text = "";
                }
                else
                {
                    txt_cstime.Text = HttpHelper.costDetailList[9].Duration.ToString();
                    txt_cscost.Text = HttpHelper.costDetailList[9].Price.ToString();
                }
                #endregion
            }
            if (HttpHelper.deviceInfoModel.Type == "Three")
            {
                #region Big
                if (HttpHelper.costDetailList[0].Duration == 0)
                {
                    txt_Btime1.Text = "";
                    txt_bcost1.Text = "";
                }
                else
                {
                    txt_Btime1.Text = HttpHelper.costDetailList[0].Duration.ToString();
                    txt_bcost1.Text = HttpHelper.costDetailList[0].Price.ToString();
                }
                if (HttpHelper.costDetailList[1].Duration == 0)
                {
                    txt_Btime2.Text = "";
                    txt_bcost2.Text = "";
                }
                else
                {
                    txt_Btime2.Text = HttpHelper.costDetailList[1].Duration.ToString();
                    txt_bcost2.Text = HttpHelper.costDetailList[1].Price.ToString();
                }
                if (HttpHelper.costDetailList[2].Duration == 0)
                {
                    txt_Btime3.Text = "";
                    txt_bcost3.Text = "";
                }
                else
                {
                    txt_Btime3.Text = HttpHelper.costDetailList[2].Duration.ToString();
                    txt_bcost3.Text = HttpHelper.costDetailList[2].Price.ToString();
                }
                if (HttpHelper.costDetailList[3].Duration == 0)
                {
                    txt_Btime4.Text = "";
                    txt_bcost4.Text = "";
                }
                else
                {
                    txt_Btime4.Text = HttpHelper.costDetailList[3].Duration.ToString();
                    txt_bcost4.Text = HttpHelper.costDetailList[3].Price.ToString();
                }
                if (HttpHelper.costDetailList[4].Duration == 0)
                {
                    txt_cBtime.Text = "";
                    txt_cbcost.Text = "";
                }
                else
                {
                    txt_cBtime.Text = HttpHelper.costDetailList[4].Duration.ToString();
                    txt_cbcost.Text = HttpHelper.costDetailList[4].Price.ToString();
                }
                #endregion

                #region Mid
                if (HttpHelper.costDetailList[5].Duration == 0)
                {
                    txt_mtime1.Text = "";
                    txt_mcost1.Text = "";
                }
                else
                {
                    txt_mtime1.Text = HttpHelper.costDetailList[5].Duration.ToString();
                    txt_mcost1.Text = HttpHelper.costDetailList[5].Price.ToString();
                }
                if (HttpHelper.costDetailList[6].Duration == 0)
                {
                    txt_mtime2.Text = "";
                    txt_mcost2.Text = "";
                }
                else
                {
                    txt_mtime2.Text = HttpHelper.costDetailList[6].Duration.ToString();
                    txt_mcost2.Text = HttpHelper.costDetailList[6].Price.ToString();
                }
                if (HttpHelper.costDetailList[7].Duration == 0)
                {
                    txt_mtime3.Text = "";
                    txt_mcost3.Text = "";
                }
                else
                {
                    txt_mtime3.Text = HttpHelper.costDetailList[7].Duration.ToString();
                    txt_mcost3.Text = HttpHelper.costDetailList[7].Price.ToString();
                }
                if (HttpHelper.costDetailList[8].Duration == 0)
                {
                    txt_mtime4.Text = "";
                    txt_mcost4.Text = "";
                }
                else
                {
                    txt_mtime4.Text = HttpHelper.costDetailList[8].Duration.ToString();
                    txt_mcost4.Text = HttpHelper.costDetailList[8].Price.ToString();
                }
                if (HttpHelper.costDetailList[9].Duration == 0)
                {
                    txt_cmtime.Text = "";
                    txt_cmcost.Text = "";
                }
                else
                {
                    txt_cmtime.Text = HttpHelper.costDetailList[9].Duration.ToString();
                    txt_cmcost.Text = HttpHelper.costDetailList[9].Price.ToString();
                }
                #endregion

                #region Small
                if (HttpHelper.costDetailList[10].Duration == 0)
                {
                    txt_stime1.Text = "";
                    txt_scost1.Text = "";
                }
                else
                {
                    txt_stime1.Text = HttpHelper.costDetailList[10].Duration.ToString();
                    txt_scost1.Text = HttpHelper.costDetailList[10].Price.ToString();
                }
                if (HttpHelper.costDetailList[11].Duration == 0)
                {
                    txt_stime2.Text = HttpHelper.costDetailList[11].Duration.ToString();
                    txt_scost2.Text = HttpHelper.costDetailList[11].Price.ToString();
                }
                else
                {
                    txt_stime2.Text = HttpHelper.costDetailList[11].Duration.ToString();
                    txt_scost2.Text = HttpHelper.costDetailList[11].Price.ToString();
                }
                if (HttpHelper.costDetailList[12].Duration == 0)
                {
                    txt_stime3.Text = "";
                    txt_scost3.Text = "";
                }
                else
                {
                    txt_stime3.Text = HttpHelper.costDetailList[12].Duration.ToString();
                    txt_scost3.Text = HttpHelper.costDetailList[12].Price.ToString();
                }
                if (HttpHelper.costDetailList[13].Duration == 0)
                {
                    txt_stime4.Text = "";
                    txt_scost4.Text = "";
                }
                else
                {
                    txt_stime4.Text = HttpHelper.costDetailList[13].Duration.ToString();
                    txt_scost4.Text = HttpHelper.costDetailList[13].Price.ToString();
                }
                if (HttpHelper.costDetailList[14].Duration == 0)
                {
                    txt_cstime.Text = "";
                    txt_cscost.Text = "";
                }
                else
                {
                    txt_cstime.Text = HttpHelper.costDetailList[14].Duration.ToString();
                    txt_cscost.Text = HttpHelper.costDetailList[14].Price.ToString();
                }
                #endregion
            }

        }

        private void txt_bcost1_TextChanged(object sender, EventArgs e)
        {

        }

        private void btn_Submit_Click(object sender, EventArgs e)
        {
            kb.Close();
            CostDetail[] costs = new CostDetail[15];
            List<CostDetail> costlist = new List<CostDetail>();
            Dictionary<string, string> parameters = new Dictionary<string, string>();
            XmlDocument xd = new XmlDocument();
            xd.Load("../DeviceData.xml");//加载XML文件
            XmlNodeList xmlNoteList = xd.GetElementsByTagName("Price");
            XmlNodeList xmlNoteDuration = xd.GetElementsByTagName("Duration");
            
            if (HttpHelper.deviceInfoModel.Type == "One")
            {
                
                if (HttpHelper.dBoxLists[0].TypeNo == "Big")
                {
                    #region 修改本地数据
                    xmlNoteList[0].InnerText = txt_Btime1.Text.Length > 0 ? txt_Btime1.Text : "0";
                    xmlNoteList[1].InnerText = txt_bcost2.Text.Length > 0 ? txt_bcost2.Text : "0";
                    xmlNoteList[2].InnerText = txt_bcost3.Text.Length > 0 ? txt_bcost3.Text : "0";
                    xmlNoteList[3].InnerText = txt_bcost4.Text.Length > 0 ? txt_bcost4.Text : "0";
                    xmlNoteList[4].InnerText = txt_cbcost.Text.Length > 0 ? txt_cbcost.Text : "0";

                    xmlNoteDuration[0].InnerText = txt_Btime1.Text.Length > 0 ? txt_Btime1.Text : "0";
                    xmlNoteDuration[1].InnerText = txt_Btime2.Text.Length > 0 ? txt_Btime2.Text : "0";
                    xmlNoteDuration[2].InnerText = txt_Btime3.Text.Length > 0 ? txt_Btime3.Text : "0";
                    xmlNoteDuration[3].InnerText = txt_Btime4.Text.Length > 0 ? txt_Btime4.Text : "0";
                    xmlNoteDuration[4].InnerText = txt_cBtime.Text.Length > 0 ? txt_cBtime.Text : "0";

                    HttpHelper.costDetailList[0].Duration = Convert.ToInt32(txt_Btime1.Text.Length > 0 ? txt_Btime1.Text : "0");
                    HttpHelper.costDetailList[1].Duration = Convert.ToInt32(txt_Btime2.Text.Length > 0 ? txt_Btime2.Text : "0");
                    HttpHelper.costDetailList[2].Duration = Convert.ToInt32(txt_Btime3.Text.Length > 0 ? txt_Btime3.Text : "0");
                    HttpHelper.costDetailList[3].Duration = Convert.ToInt32(txt_Btime4.Text.Length > 0 ? txt_Btime4.Text : "0");
                    HttpHelper.costDetailList[4].Duration = Convert.ToInt32(txt_cBtime.Text.Length > 0 ? txt_cBtime.Text : "0");
                    HttpHelper.costDetailList[0].Price = Convert.ToDecimal(txt_bcost1.Text.Length > 0 ? txt_bcost1.Text : "0");
                    HttpHelper.costDetailList[1].Price = Convert.ToDecimal(txt_bcost2.Text.Length > 0 ? txt_bcost2.Text : "0");
                    HttpHelper.costDetailList[2].Price = Convert.ToDecimal(txt_bcost3.Text.Length > 0 ? txt_bcost3.Text : "0");
                    HttpHelper.costDetailList[3].Price = Convert.ToDecimal(txt_bcost4.Text.Length > 0 ? txt_bcost4.Text : "0");
                    HttpHelper.costDetailList[4].Price = Convert.ToDecimal(txt_cbcost.Text.Length > 0 ? txt_cbcost.Text : "0");
                    #endregion
                    #region big
                    CostDetail costs1 = new CostDetail
                    {
                        Duration = Convert.ToInt32(txt_Btime1.Text.Length > 0 ? txt_Btime1.Text : "0"),
                        Price = Convert.ToDecimal(txt_bcost1.Text.Length > 0 ? txt_bcost1.Text : "0"),
                        PriceType = "N",
                        TypeNo = "Big"
                    };
                    costlist.Add(costs1);

                    CostDetail cost2 = new CostDetail
                    {
                        Duration = Convert.ToInt32(txt_Btime2.Text.Length > 0 ? txt_Btime2.Text : "0"),
                        Price = Convert.ToDecimal(txt_bcost2.Text.Length > 0 ? txt_bcost2.Text : "0"),
                        PriceType = "N",
                        TypeNo = "Big"
                    };
                    costlist.Add(cost2);

                    CostDetail cost3 = new CostDetail
                    {
                        Duration = Convert.ToInt32(txt_Btime3.Text.Length > 0 ? txt_Btime3.Text : "0"),
                        Price = Convert.ToDecimal(txt_bcost3.Text.Length > 0 ? txt_bcost3.Text : "0"),
                        PriceType = "N",
                        TypeNo = "Big"
                    };
                    costlist.Add(cost3);

                    CostDetail cost4 = new CostDetail
                    {
                        Duration = Convert.ToInt32(txt_Btime4.Text.Length > 0 ? txt_Btime4.Text : "0"),
                        Price = Convert.ToDecimal(txt_bcost4.Text.Length > 0 ? txt_bcost4.Text : "0"),
                        PriceType = "N",
                        TypeNo = "Big"
                    };
                    costlist.Add(cost4);

                    CostDetail cost5 = new CostDetail
                    {
                        Duration = Convert.ToInt32(txt_cBtime.Text.Length > 0 ? txt_cBtime.Text : "0"),
                        Price = Convert.ToDecimal(txt_cbcost.Text.Length > 0 ? txt_cbcost.Text : "0"),
                        PriceType = "E",
                        TypeNo = "Big"
                    };
                    costlist.Add(cost5);
                    #endregion
                }
                if(HttpHelper.dBoxLists[0].TypeNo == "Mid")
                {
                    #region 修改本地数据
                    xmlNoteList[0].InnerText = txt_mcost1.Text.Length > 0 ? txt_mcost1.Text : "0";
                    xmlNoteList[1].InnerText = txt_mcost2.Text.Length > 0 ? txt_mcost2.Text : "0";
                    xmlNoteList[2].InnerText = txt_mcost3.Text.Length > 0 ? txt_mcost3.Text : "0";
                    xmlNoteList[3].InnerText = txt_mcost4.Text.Length > 0 ? txt_mcost4.Text : "0";
                    xmlNoteList[4].InnerText = txt_cmcost.Text.Length > 0 ? txt_cmcost.Text : "0";

                    xmlNoteDuration[0].InnerText = txt_mtime1.Text.Length > 0 ? txt_mtime1.Text : "0";
                    xmlNoteDuration[1].InnerText = txt_mtime2.Text.Length > 0 ? txt_mtime2.Text : "0";
                    xmlNoteDuration[2].InnerText = txt_mtime3.Text.Length > 0 ? txt_mtime3.Text : "0";
                    xmlNoteDuration[3].InnerText = txt_mtime4.Text.Length > 0 ? txt_mtime4.Text : "0";
                    xmlNoteDuration[4].InnerText = txt_cmtime.Text.Length > 0 ? txt_cmtime.Text : "0";

                    HttpHelper.costDetailList[0].Duration = Convert.ToInt32(txt_mtime1.Text.Length > 0 ? txt_mtime1.Text : "0");
                    HttpHelper.costDetailList[1].Duration = Convert.ToInt32(txt_mtime2.Text.Length > 0 ? txt_mtime2.Text : "0");
                    HttpHelper.costDetailList[2].Duration = Convert.ToInt32(txt_mtime3.Text.Length > 0 ? txt_mtime3.Text : "0");
                    HttpHelper.costDetailList[3].Duration = Convert.ToInt32(txt_mtime4.Text.Length > 0 ? txt_mtime4.Text : "0");
                    HttpHelper.costDetailList[4].Duration = Convert.ToInt32(txt_cmtime.Text.Length > 0 ? txt_cmtime.Text : "0");
                    HttpHelper.costDetailList[0].Price = Convert.ToDecimal(txt_mcost1.Text.Length > 0 ? txt_mcost1.Text : "0");
                    HttpHelper.costDetailList[1].Price = Convert.ToDecimal(txt_mcost2.Text.Length > 0 ? txt_mcost2.Text : "0");
                    HttpHelper.costDetailList[2].Price = Convert.ToDecimal(txt_mcost3.Text.Length > 0 ? txt_mcost3.Text : "0");
                    HttpHelper.costDetailList[3].Price = Convert.ToDecimal(txt_mcost4.Text.Length > 0 ? txt_mcost4.Text : "0");
                    HttpHelper.costDetailList[4].Price = Convert.ToDecimal(txt_cmcost.Text.Length > 0 ? txt_cmcost.Text : "0");
                    #endregion
                    #region Mid
                    CostDetail cost6 = new CostDetail
                    {
                        Duration = Convert.ToInt32(txt_mtime1.Text.Length > 0 ? txt_mtime1.Text : "0"),
                        Price = Convert.ToDecimal(txt_mcost1.Text.Length > 0 ? txt_mcost1.Text : "0"),
                        PriceType = "N",
                        TypeNo = "Mid"
                    };
                    costlist.Add(cost6);

                    CostDetail cost7 = new CostDetail
                    {
                        Duration = Convert.ToInt32(txt_mtime2.Text.Length > 0 ? txt_mtime2.Text : "0"),
                        Price = Convert.ToDecimal(txt_mcost2.Text.Length > 0 ? txt_mcost2.Text : "0"),
                        PriceType = "N",
                        TypeNo = "Mid"
                    };
                    costlist.Add(cost7);

                    CostDetail cost8 = new CostDetail
                    {
                        Duration = Convert.ToInt32(txt_mtime3.Text.Length > 0 ? txt_mtime3.Text : "0"),
                        Price = Convert.ToDecimal(txt_mcost3.Text.Length > 0 ? txt_mcost3.Text : "0"),
                        PriceType = "N",
                        TypeNo = "Mid"
                    };
                    costlist.Add(cost8);

                    CostDetail cost9 = new CostDetail
                    {
                        Duration = Convert.ToInt32(txt_mtime4.Text.Length > 0 ? txt_mtime4.Text : "0"),
                        Price = Convert.ToDecimal(txt_mcost4.Text.Length > 0 ? txt_mcost4.Text : "0"),
                        PriceType = "N",
                        TypeNo = "Mid"
                    };
                    costlist.Add(cost9);

                    CostDetail cost10 = new CostDetail
                    {
                        Duration = Convert.ToInt32(txt_cmtime.Text.Length > 0 ? txt_cmtime.Text : "0"),
                        Price = Convert.ToDecimal(txt_cmcost.Text.Length > 0 ? txt_cmcost.Text : "0"),
                        PriceType = "E",
                        TypeNo = "Mid"
                    };
                    costlist.Add(cost10);
                    #endregion                    
                }
                if (HttpHelper.dBoxLists[0].TypeNo == "Small")
                {
                    #region 修改本地数据
                    xmlNoteList[0].InnerText = txt_scost1.Text.Length > 0 ? txt_scost1.Text : "0";
                    xmlNoteList[1].InnerText = txt_scost2.Text.Length > 0 ? txt_scost2.Text : "0";
                    xmlNoteList[2].InnerText = txt_scost3.Text.Length > 0 ? txt_scost3.Text : "0";
                    xmlNoteList[3].InnerText = txt_scost4.Text.Length > 0 ? txt_scost4.Text : "0";
                    xmlNoteList[4].InnerText = txt_cscost.Text.Length > 0 ? txt_cscost.Text : "0";

                    xmlNoteDuration[0].InnerText = txt_stime1.Text.Length > 0 ? txt_stime1.Text : "0";
                    xmlNoteDuration[1].InnerText = txt_stime2.Text.Length > 0 ? txt_stime2.Text : "0";
                    xmlNoteDuration[2].InnerText = txt_stime3.Text.Length > 0 ? txt_stime3.Text : "0";
                    xmlNoteDuration[3].InnerText = txt_stime4.Text.Length > 0 ? txt_stime4.Text : "0";
                    xmlNoteDuration[4].InnerText = txt_cstime.Text.Length > 0 ? txt_cstime.Text : "0";

                    HttpHelper.costDetailList[0].Duration = Convert.ToInt32(txt_stime1.Text.Length > 0 ? txt_stime1.Text : "0");
                    HttpHelper.costDetailList[1].Duration = Convert.ToInt32(txt_stime2.Text.Length > 0 ? txt_stime2.Text : "0");
                    HttpHelper.costDetailList[2].Duration = Convert.ToInt32(txt_stime3.Text.Length > 0 ? txt_stime3.Text : "0");
                    HttpHelper.costDetailList[3].Duration = Convert.ToInt32(txt_stime4.Text.Length > 0 ? txt_stime4.Text : "0");
                    HttpHelper.costDetailList[4].Duration = Convert.ToInt32(txt_cstime.Text.Length > 0 ? txt_cstime.Text : "0");
                    HttpHelper.costDetailList[0].Price = Convert.ToDecimal(txt_scost1.Text.Length > 0 ? txt_scost1.Text : "0");
                    HttpHelper.costDetailList[1].Price = Convert.ToDecimal(txt_scost2.Text.Length > 0 ? txt_scost2.Text : "0");
                    HttpHelper.costDetailList[2].Price = Convert.ToDecimal(txt_scost3.Text.Length > 0 ? txt_scost3.Text : "0");
                    HttpHelper.costDetailList[3].Price = Convert.ToDecimal(txt_scost4.Text.Length > 0 ? txt_scost4.Text : "0");
                    HttpHelper.costDetailList[4].Price = Convert.ToDecimal(txt_cscost.Text.Length > 0 ? txt_cscost.Text : "0");
                    #endregion
                    #region Small
                    CostDetail cost11 = new CostDetail
                    {
                        Duration = Convert.ToInt32(txt_stime1.Text.Length > 0 ? txt_stime1.Text : "0"),
                        Price = Convert.ToDecimal(txt_scost1.Text.Length > 0 ? txt_scost1.Text : "0"),
                        PriceType = "N",
                        TypeNo = "Small"
                    };
                    costlist.Add(cost11);

                    CostDetail cost12 = new CostDetail
                    {
                        Duration = Convert.ToInt32(txt_stime2.Text.Length > 0 ? txt_stime2.Text : "0"),
                        Price = Convert.ToDecimal(txt_scost2.Text.Length > 0 ? txt_scost2.Text : "0"),
                        PriceType = "N",
                        TypeNo = "Small"
                    };
                    costlist.Add(cost12);

                    CostDetail cost13 = new CostDetail
                    {
                        Duration = Convert.ToInt32(txt_stime3.Text.Length > 0 ? txt_stime3.Text : "0"),
                        Price = Convert.ToDecimal(txt_scost3.Text.Length > 0 ? txt_scost3.Text : "0"),
                        PriceType = "N",
                        TypeNo = "Small"
                    };
                    costlist.Add(cost13);

                    CostDetail cost14 = new CostDetail
                    {
                        Duration = Convert.ToInt32(txt_stime4.Text.Length > 0 ? txt_stime4.Text : "0"),
                        Price = Convert.ToDecimal(txt_scost4.Text.Length > 0 ? txt_scost4.Text : "0"),
                        PriceType = "N",
                        TypeNo = "Small"
                    };
                    costlist.Add(cost14);

                    CostDetail cost15 = new CostDetail
                    {
                        Duration = Convert.ToInt32(txt_cstime.Text.Length > 0 ? txt_cstime.Text : "0"),
                        Price = Convert.ToDecimal(txt_cscost.Text.Length > 0 ? txt_cscost.Text : "0"),
                        PriceType = "E",
                        TypeNo = "Small"
                    };
                    costlist.Add(cost15);
                    #endregion   
                }
            }
            if(HttpHelper.deviceInfoModel.Type == "Two")
            {
                #region 修改本地数据
                xmlNoteList[0].InnerText = txt_bcost1.Text.Length > 0 ? txt_bcost1.Text : "0";
                xmlNoteList[1].InnerText = txt_bcost2.Text.Length > 0 ? txt_bcost2.Text : "0";
                xmlNoteList[2].InnerText = txt_bcost3.Text.Length > 0 ? txt_bcost3.Text : "0";
                xmlNoteList[3].InnerText = txt_bcost4.Text.Length > 0 ? txt_bcost4.Text : "0";
                xmlNoteList[4].InnerText = txt_cbcost.Text.Length > 0 ? txt_cbcost.Text : "0";
                xmlNoteList[5].InnerText = txt_scost1.Text.Length > 0 ? txt_scost1.Text : "0";
                xmlNoteList[6].InnerText = txt_scost2.Text.Length > 0 ? txt_scost2.Text : "0";
                xmlNoteList[7].InnerText = txt_scost3.Text.Length > 0 ? txt_scost3.Text : "0";
                xmlNoteList[8].InnerText = txt_scost4.Text.Length > 0 ? txt_scost4.Text : "0";
                xmlNoteList[9].InnerText = txt_cscost.Text.Length > 0 ? txt_cscost.Text : "0";

                xmlNoteDuration[0].InnerText = txt_Btime1.Text.Length > 0 ? txt_Btime1.Text : "0";
                xmlNoteDuration[1].InnerText = txt_Btime2.Text.Length > 0 ? txt_Btime2.Text : "0";
                xmlNoteDuration[2].InnerText = txt_Btime3.Text.Length > 0 ? txt_Btime3.Text : "0";
                xmlNoteDuration[3].InnerText = txt_Btime4.Text.Length > 0 ? txt_Btime4.Text : "0";
                xmlNoteDuration[4].InnerText = txt_cBtime.Text.Length > 0 ? txt_cBtime.Text : "0";
                xmlNoteDuration[5].InnerText = txt_stime1.Text.Length > 0 ? txt_stime1.Text : "0";
                xmlNoteDuration[6].InnerText = txt_stime2.Text.Length > 0 ? txt_stime2.Text : "0";
                xmlNoteDuration[7].InnerText = txt_stime3.Text.Length > 0 ? txt_stime3.Text : "0";
                xmlNoteDuration[8].InnerText = txt_stime4.Text.Length > 0 ? txt_stime4.Text : "0";
                xmlNoteDuration[9].InnerText = txt_cstime.Text.Length > 0 ? txt_cstime.Text : "0";

                HttpHelper.costDetailList[0].Duration = Convert.ToInt32(txt_Btime1.Text.Length > 0 ? txt_Btime1.Text : "0");
                HttpHelper.costDetailList[1].Duration = Convert.ToInt32(txt_Btime2.Text.Length > 0 ? txt_Btime2.Text : "0");
                HttpHelper.costDetailList[2].Duration = Convert.ToInt32(txt_Btime3.Text.Length > 0 ? txt_Btime3.Text : "0");
                HttpHelper.costDetailList[3].Duration = Convert.ToInt32(txt_Btime4.Text.Length > 0 ? txt_Btime4.Text : "0");
                HttpHelper.costDetailList[4].Duration = Convert.ToInt32(txt_cBtime.Text.Length > 0 ? txt_cBtime.Text : "0");
                HttpHelper.costDetailList[5].Duration = Convert.ToInt32(txt_stime1.Text.Length > 0 ? txt_stime1.Text : "0");
                HttpHelper.costDetailList[6].Duration = Convert.ToInt32(txt_stime2.Text.Length > 0 ? txt_stime2.Text : "0");
                HttpHelper.costDetailList[7].Duration = Convert.ToInt32(txt_stime3.Text.Length > 0 ? txt_stime3.Text : "0");
                HttpHelper.costDetailList[8].Duration = Convert.ToInt32(txt_stime4.Text.Length > 0 ? txt_stime4.Text : "0");
                HttpHelper.costDetailList[9].Duration = Convert.ToInt32(txt_cstime.Text.Length > 0 ? txt_cstime.Text : "0");
                HttpHelper.costDetailList[0].Price = Convert.ToDecimal(txt_bcost1.Text.Length > 0 ? txt_bcost1.Text : "0");
                HttpHelper.costDetailList[1].Price = Convert.ToDecimal(txt_bcost2.Text.Length > 0 ? txt_bcost2.Text : "0");
                HttpHelper.costDetailList[2].Price = Convert.ToDecimal(txt_bcost3.Text.Length > 0 ? txt_bcost3.Text : "0");
                HttpHelper.costDetailList[3].Price = Convert.ToDecimal(txt_bcost4.Text.Length > 0 ? txt_bcost4.Text : "0");
                HttpHelper.costDetailList[4].Price = Convert.ToDecimal(txt_cbcost.Text.Length > 0 ? txt_cbcost.Text : "0");
                HttpHelper.costDetailList[5].Price = Convert.ToDecimal(txt_scost1.Text.Length > 0 ? txt_scost1.Text : "0");
                HttpHelper.costDetailList[6].Price = Convert.ToDecimal(txt_scost2.Text.Length > 0 ? txt_scost2.Text : "0");
                HttpHelper.costDetailList[7].Price = Convert.ToDecimal(txt_scost3.Text.Length > 0 ? txt_scost3.Text : "0");
                HttpHelper.costDetailList[8].Price = Convert.ToDecimal(txt_scost4.Text.Length > 0 ? txt_scost4.Text : "0");
                HttpHelper.costDetailList[9].Price = Convert.ToDecimal(txt_cscost.Text.Length > 0 ? txt_cscost.Text : "0"); 
                #endregion
                #region big
                CostDetail costs1 = new CostDetail
                {
                    Duration = Convert.ToInt32(txt_Btime1.Text.Length > 0 ? txt_Btime1.Text : "0"),
                    Price = Convert.ToDecimal(txt_bcost1.Text.Length > 0 ? txt_bcost1.Text : "0"),
                    PriceType = "N",
                    TypeNo = "Big"
                };
                costlist.Add(costs1);

                CostDetail cost2 = new CostDetail
                {
                    Duration = Convert.ToInt32(txt_Btime2.Text.Length > 0 ? txt_Btime2.Text : "0"),
                    Price = Convert.ToDecimal(txt_bcost2.Text.Length > 0 ? txt_bcost2.Text : "0"),
                    PriceType = "N",
                    TypeNo = "Big"
                };
                costlist.Add(cost2);

                CostDetail cost3 = new CostDetail
                {
                    Duration = Convert.ToInt32(txt_Btime3.Text.Length > 0 ? txt_Btime3.Text : "0"),
                    Price = Convert.ToDecimal(txt_bcost3.Text.Length > 0 ? txt_bcost3.Text : "0"),
                    PriceType = "N",
                    TypeNo = "Big"
                };
                costlist.Add(cost3);

                CostDetail cost4 = new CostDetail
                {
                    Duration = Convert.ToInt32(txt_Btime4.Text.Length > 0 ? txt_Btime4.Text : "0"),
                    Price = Convert.ToDecimal(txt_bcost4.Text.Length > 0 ? txt_bcost4.Text : "0"),
                    PriceType = "N",
                    TypeNo = "Big"
                };
                costlist.Add(cost4);

                CostDetail cost5 = new CostDetail
                {
                    Duration = Convert.ToInt32(txt_cBtime.Text.Length > 0 ? txt_cBtime.Text : "0"),
                    Price = Convert.ToDecimal(txt_cbcost.Text.Length > 0 ? txt_cbcost.Text : "0"),
                    PriceType = "E",
                    TypeNo = "Big"
                };
                costlist.Add(cost5);
                #endregion
                #region Small
                CostDetail cost11 = new CostDetail
                {
                    Duration = Convert.ToInt32(txt_stime1.Text.Length > 0 ? txt_stime1.Text : "0"),
                    Price = Convert.ToDecimal(txt_scost1.Text.Length > 0 ? txt_scost1.Text : "0"),
                    PriceType = "N",
                    TypeNo = "Small"
                };
                costlist.Add(cost11);

                CostDetail cost12 = new CostDetail
                {
                    Duration = Convert.ToInt32(txt_stime2.Text.Length > 0 ? txt_stime2.Text : "0"),
                    Price = Convert.ToDecimal(txt_scost2.Text.Length > 0 ? txt_scost2.Text : "0"),
                    PriceType = "N",
                    TypeNo = "Small"
                };
                costlist.Add(cost12);

                CostDetail cost13 = new CostDetail
                {
                    Duration = Convert.ToInt32(txt_stime3.Text.Length > 0 ? txt_stime3.Text : "0"),
                    Price = Convert.ToDecimal(txt_scost3.Text.Length > 0 ? txt_scost3.Text : "0"),
                    PriceType = "N",
                    TypeNo = "Small"
                };
                costlist.Add(cost13);

                CostDetail cost14 = new CostDetail
                {
                    Duration = Convert.ToInt32(txt_stime4.Text.Length > 0 ? txt_stime4.Text : "0"),
                    Price = Convert.ToDecimal(txt_scost4.Text.Length > 0 ? txt_scost4.Text : "0"),
                    PriceType = "N",
                    TypeNo = "Small"
                };
                costlist.Add(cost14);

                CostDetail cost15 = new CostDetail
                {
                    Duration = Convert.ToInt32(txt_cstime.Text.Length > 0 ? txt_cstime.Text : "0"),
                    Price = Convert.ToDecimal(txt_cscost.Text.Length > 0 ? txt_cscost.Text : "0"),
                    PriceType = "E",
                    TypeNo = "Small"
                };
                costlist.Add(cost15);
                #endregion
            }
            if(HttpHelper.deviceInfoModel.Type == "Three")
            {
                #region 修改本地数据
                #region duration
                xmlNoteDuration[0].InnerText = txt_Btime1.Text.Length > 0 ? txt_Btime1.Text : "0";
                xmlNoteDuration[1].InnerText = txt_Btime2.Text.Length > 0 ? txt_Btime2.Text : "0";
                xmlNoteDuration[2].InnerText = txt_Btime3.Text.Length > 0 ? txt_Btime3.Text : "0";
                xmlNoteDuration[3].InnerText = txt_Btime4.Text.Length > 0 ? txt_Btime4.Text : "0";
                xmlNoteDuration[4].InnerText = txt_cBtime.Text.Length > 0 ? txt_cBtime.Text : "0";
                xmlNoteDuration[5].InnerText = txt_mtime1.Text.Length > 0 ? txt_mtime1.Text : "0";
                xmlNoteDuration[6].InnerText = txt_mtime2.Text.Length > 0 ? txt_mtime2.Text : "0";
                xmlNoteDuration[7].InnerText = txt_mtime3.Text.Length > 0 ? txt_mtime3.Text : "0";
                xmlNoteDuration[8].InnerText = txt_mtime4.Text.Length > 0 ? txt_mtime4.Text : "0";
                xmlNoteDuration[9].InnerText = txt_cmtime.Text.Length > 0 ? txt_cmtime.Text : "0";
                xmlNoteDuration[10].InnerText = txt_stime1.Text.Length > 0 ? txt_stime1.Text : "0";
                xmlNoteDuration[11].InnerText = txt_stime2.Text.Length > 0 ? txt_stime2.Text : "0";
                xmlNoteDuration[12].InnerText = txt_stime3.Text.Length > 0 ? txt_stime3.Text : "0";
                xmlNoteDuration[13].InnerText = txt_stime4.Text.Length > 0 ? txt_stime4.Text : "0";
                xmlNoteDuration[14].InnerText = txt_cstime.Text.Length > 0 ? txt_cstime.Text : "0";

                HttpHelper.costDetailList[0].Duration = Convert.ToInt32(txt_Btime1.Text.Length > 0 ? txt_Btime1.Text : "0");
                HttpHelper.costDetailList[1].Duration = Convert.ToInt32(txt_Btime2.Text.Length > 0 ? txt_Btime2.Text : "0");
                HttpHelper.costDetailList[2].Duration = Convert.ToInt32(txt_Btime3.Text.Length > 0 ? txt_Btime3.Text : "0");
                HttpHelper.costDetailList[3].Duration = Convert.ToInt32(txt_Btime4.Text.Length > 0 ? txt_Btime4.Text : "0");
                HttpHelper.costDetailList[4].Duration = Convert.ToInt32(txt_cBtime.Text.Length > 0 ? txt_cBtime.Text : "0");
                HttpHelper.costDetailList[5].Duration = Convert.ToInt32(txt_mtime1.Text.Length > 0 ? txt_mtime1.Text : "0");
                HttpHelper.costDetailList[6].Duration = Convert.ToInt32(txt_mtime2.Text.Length > 0 ? txt_mtime2.Text : "0");
                HttpHelper.costDetailList[7].Duration = Convert.ToInt32(txt_mtime3.Text.Length > 0 ? txt_mtime3.Text : "0");
                HttpHelper.costDetailList[8].Duration = Convert.ToInt32(txt_mtime4.Text.Length > 0 ? txt_mtime4.Text : "0");
                HttpHelper.costDetailList[9].Duration = Convert.ToInt32(txt_cmtime.Text.Length > 0 ? txt_cmtime.Text : "0");
                HttpHelper.costDetailList[10].Duration = Convert.ToInt32(txt_stime1.Text.Length > 0 ? txt_stime1.Text : "0");
                HttpHelper.costDetailList[11].Duration = Convert.ToInt32(txt_stime2.Text.Length > 0 ? txt_stime2.Text : "0");
                HttpHelper.costDetailList[12].Duration = Convert.ToInt32(txt_stime3.Text.Length > 0 ? txt_stime3.Text : "0");
                HttpHelper.costDetailList[13].Duration = Convert.ToInt32(txt_stime4.Text.Length > 0 ? txt_stime4.Text : "0");
                HttpHelper.costDetailList[14].Duration = Convert.ToInt32(txt_cstime.Text.Length > 0 ? txt_cstime.Text : "0");
                #endregion

                #region price
                xmlNoteList[0].InnerText = txt_Btime1.Text.Length > 0 ? txt_Btime1.Text : "0";
                xmlNoteList[1].InnerText = txt_bcost2.Text.Length > 0 ? txt_bcost2.Text : "0";
                xmlNoteList[2].InnerText = txt_bcost3.Text.Length > 0 ? txt_bcost3.Text : "0";
                xmlNoteList[3].InnerText = txt_bcost4.Text.Length > 0 ? txt_bcost4.Text : "0";
                xmlNoteList[4].InnerText = txt_cbcost.Text.Length > 0 ? txt_cbcost.Text : "0";
                xmlNoteList[5].InnerText = txt_mcost1.Text.Length > 0 ? txt_mcost1.Text : "0";
                xmlNoteList[6].InnerText = txt_mcost2.Text.Length > 0 ? txt_mcost2.Text : "0";
                xmlNoteList[7].InnerText = txt_mcost3.Text.Length > 0 ? txt_mcost3.Text : "0";
                xmlNoteList[8].InnerText = txt_mcost4.Text.Length > 0 ? txt_mcost4.Text : "0";
                xmlNoteList[9].InnerText = txt_cmcost.Text.Length > 0 ? txt_cmcost.Text : "0";
                xmlNoteList[10].InnerText = txt_scost1.Text.Length > 0 ? txt_scost1.Text : "0";
                xmlNoteList[11].InnerText = txt_scost2.Text.Length > 0 ? txt_scost2.Text : "0";
                xmlNoteList[12].InnerText = txt_scost3.Text.Length > 0 ? txt_scost3.Text : "0";
                xmlNoteList[13].InnerText = txt_scost4.Text.Length > 0 ? txt_scost4.Text : "0";
                xmlNoteList[14].InnerText = txt_cscost.Text.Length > 0 ? txt_cscost.Text : "0";

                HttpHelper.costDetailList[0].Price = Convert.ToDecimal(txt_bcost1.Text.Length > 0 ? txt_bcost1.Text : "0");
                HttpHelper.costDetailList[1].Price = Convert.ToDecimal(txt_bcost2.Text.Length > 0 ? txt_bcost2.Text : "0");
                HttpHelper.costDetailList[2].Price = Convert.ToDecimal(txt_bcost3.Text.Length > 0 ? txt_bcost3.Text : "0");
                HttpHelper.costDetailList[3].Price = Convert.ToDecimal(txt_bcost4.Text.Length > 0 ? txt_bcost4.Text : "0");
                HttpHelper.costDetailList[4].Price = Convert.ToDecimal(txt_cbcost.Text.Length > 0 ? txt_cbcost.Text : "0");
                HttpHelper.costDetailList[5].Price = Convert.ToDecimal(txt_mcost1.Text.Length > 0 ? txt_mcost1.Text : "0");
                HttpHelper.costDetailList[6].Price = Convert.ToDecimal(txt_mcost2.Text.Length > 0 ? txt_mcost2.Text : "0");
                HttpHelper.costDetailList[7].Price = Convert.ToDecimal(txt_mcost3.Text.Length > 0 ? txt_mcost3.Text : "0");
                HttpHelper.costDetailList[8].Price = Convert.ToDecimal(txt_mcost4.Text.Length > 0 ? txt_mcost4.Text : "0");
                HttpHelper.costDetailList[9].Price = Convert.ToDecimal(txt_cmcost.Text.Length > 0 ? txt_cmcost.Text : "0");
                HttpHelper.costDetailList[10].Price = Convert.ToDecimal(txt_scost1.Text.Length > 0 ? txt_scost1.Text : "0");
                HttpHelper.costDetailList[11].Price = Convert.ToDecimal(txt_scost2.Text.Length > 0 ? txt_scost2.Text : "0");
                HttpHelper.costDetailList[12].Price = Convert.ToDecimal(txt_scost3.Text.Length > 0 ? txt_scost3.Text : "0");
                HttpHelper.costDetailList[13].Price = Convert.ToDecimal(txt_scost4.Text.Length > 0 ? txt_scost4.Text : "0");
                HttpHelper.costDetailList[14].Price = Convert.ToDecimal(txt_cscost.Text.Length > 0 ? txt_cscost.Text : "0");
                #endregion 
                #endregion
                #region big
                CostDetail costs1 = new CostDetail
                {
                    Duration = Convert.ToInt32(txt_Btime1.Text.Length > 0 ? txt_Btime1.Text : "0"),
                    Price = Convert.ToDecimal(txt_bcost1.Text.Length > 0 ? txt_bcost1.Text : "0"),
                    PriceType = "N",
                    TypeNo = "Big"
                };
                costlist.Add(costs1);

                CostDetail cost2 = new CostDetail
                {
                    Duration = Convert.ToInt32(txt_Btime2.Text.Length > 0 ? txt_Btime2.Text : "0"),
                    Price = Convert.ToDecimal(txt_bcost2.Text.Length > 0 ? txt_bcost2.Text : "0"),
                    PriceType = "N",
                    TypeNo = "Big"
                };
                costlist.Add(cost2);

                CostDetail cost3 = new CostDetail
                {
                    Duration = Convert.ToInt32(txt_Btime3.Text.Length > 0 ? txt_Btime3.Text : "0"),
                    Price = Convert.ToDecimal(txt_bcost3.Text.Length > 0 ? txt_bcost3.Text : "0"),
                    PriceType = "N",
                    TypeNo = "Big"
                };
                costlist.Add(cost3);

                CostDetail cost4 = new CostDetail
                {
                    Duration = Convert.ToInt32(txt_Btime4.Text.Length > 0 ? txt_Btime4.Text : "0"),
                    Price = Convert.ToDecimal(txt_bcost4.Text.Length > 0 ? txt_bcost4.Text : "0"),
                    PriceType = "N",
                    TypeNo = "Big"
                };
                costlist.Add(cost4);

                CostDetail cost5 = new CostDetail
                {
                    Duration = Convert.ToInt32(txt_cBtime.Text.Length > 0 ? txt_cBtime.Text : "0"),
                    Price = Convert.ToDecimal(txt_cbcost.Text.Length > 0 ? txt_cbcost.Text : "0"),
                    PriceType = "E",
                    TypeNo = "Big"
                };
                costlist.Add(cost5);
                #endregion
                #region Mid
                CostDetail cost6 = new CostDetail
                {
                    Duration = Convert.ToInt32(txt_mtime1.Text.Length > 0 ? txt_mtime1.Text : "0"),
                    Price = Convert.ToDecimal(txt_mcost1.Text.Length > 0 ? txt_mcost1.Text : "0"),
                    PriceType = "N",
                    TypeNo = "Mid"
                };
                costlist.Add(cost6);

                CostDetail cost7 = new CostDetail
                {
                    Duration = Convert.ToInt32(txt_mtime2.Text.Length > 0 ? txt_mtime2.Text : "0"),
                    Price = Convert.ToDecimal(txt_mcost2.Text.Length > 0 ? txt_mcost2.Text : "0"),
                    PriceType = "N",
                    TypeNo = "Mid"
                };
                costlist.Add(cost7);

                CostDetail cost8 = new CostDetail
                {
                    Duration = Convert.ToInt32(txt_mtime3.Text.Length > 0 ? txt_mtime3.Text : "0"),
                    Price = Convert.ToDecimal(txt_mcost3.Text.Length > 0 ? txt_mcost3.Text : "0"),
                    PriceType = "N",
                    TypeNo = "Mid"
                };
                costlist.Add(cost8);

                CostDetail cost9 = new CostDetail
                {
                    Duration = Convert.ToInt32(txt_mtime4.Text.Length > 0 ? txt_mtime4.Text : "0"),
                    Price = Convert.ToDecimal(txt_mcost4.Text.Length > 0 ? txt_mcost4.Text : "0"),
                    PriceType = "N",
                    TypeNo = "Mid"
                };
                costlist.Add(cost9);

                CostDetail cost10 = new CostDetail
                {
                    Duration = Convert.ToInt32(txt_cmtime.Text.Length > 0 ? txt_cmtime.Text : "0"),
                    Price = Convert.ToDecimal(txt_cmcost.Text.Length > 0 ? txt_cmcost.Text : "0"),
                    PriceType = "E",
                    TypeNo = "Mid"
                };
                costlist.Add(cost10);
                #endregion
                #region Small
                CostDetail cost11 = new CostDetail
                {
                    Duration = Convert.ToInt32(txt_stime1.Text.Length > 0 ? txt_stime1.Text : "0"),
                    Price = Convert.ToDecimal(txt_scost1.Text.Length > 0 ? txt_scost1.Text : "0"),
                    PriceType = "N",
                    TypeNo = "Small"
                };
                costlist.Add(cost11);

                CostDetail cost12 = new CostDetail
                {
                    Duration = Convert.ToInt32(txt_stime2.Text.Length > 0 ? txt_stime2.Text : "0"),
                    Price = Convert.ToDecimal(txt_scost2.Text.Length > 0 ? txt_scost2.Text : "0"),
                    PriceType = "N",
                    TypeNo = "Small"
                };
                costlist.Add(cost12);

                CostDetail cost13 = new CostDetail
                {
                    Duration = Convert.ToInt32(txt_stime3.Text.Length > 0 ? txt_stime3.Text : "0"),
                    Price = Convert.ToDecimal(txt_scost3.Text.Length > 0 ? txt_scost3.Text : "0"),
                    PriceType = "N",
                    TypeNo = "Small"
                };
                costlist.Add(cost13);

                CostDetail cost14 = new CostDetail
                {
                    Duration = Convert.ToInt32(txt_stime4.Text.Length > 0 ? txt_stime4.Text : "0"),
                    Price = Convert.ToDecimal(txt_scost4.Text.Length > 0 ? txt_scost4.Text : "0"),
                    PriceType = "N",
                    TypeNo = "Small"
                };
                costlist.Add(cost14);

                CostDetail cost15 = new CostDetail
                {
                    Duration = Convert.ToInt32(txt_cstime.Text.Length > 0 ? txt_cstime.Text : "0"),
                    Price = Convert.ToDecimal(txt_cscost.Text.Length > 0 ? txt_cscost.Text : "0"),
                    PriceType = "E",
                    TypeNo = "Small"
                };
                costlist.Add(cost15);
                #endregion
            }
            xd.Save("../DeviceData.xml");
            parameters.Add("piId", HttpHelper.deviceInfoModel.DId.ToString());
            parameters.Add("priceJson", JsonConvert.SerializeObject(costlist));
            string url = "TerminalInfo/SubmitCostTemplate1";
            var res = HttpHelper.Post(parameters, url, 10);
            if (res.status == "OK")
            {
                MessageBox.Show("修改成功");
            }
            else
            {
                MessageBox.Show("修改失败");
            }
        }
        CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
        private void button1_Click_1(object sender, EventArgs e)
        {
            kb.Close();
            this.Hide();
            new Index().Show();
        }

        private void txt_Btime1_MouseCaptureChanged(object sender, EventArgs e)
        {

        }

        private void txt_Btime1_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_Btime1.Location).X+65, PointToScreen(txt_Btime1.Location).Y+180);
            txt_Btime1.Focus();
            txt_Btime1.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_bcost1_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_bcost1.Location).X + 65, PointToScreen(txt_bcost1.Location).Y + 180);
            txt_bcost1.Focus();
            txt_bcost1.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_Btime2_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_Btime2.Location).X + 65, PointToScreen(txt_Btime2.Location).Y + 180);
            txt_Btime2.Focus();
            txt_Btime2.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_bcost2_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_bcost2.Location).X + 65, PointToScreen(txt_bcost2.Location).Y + 180);
            txt_bcost2.Focus();
            txt_bcost2.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_Btime3_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_Btime3.Location).X + 65, PointToScreen(txt_Btime3.Location).Y + 180);
            txt_Btime3.Focus();
            txt_Btime3.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_bcost3_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_bcost3.Location).X + 65, PointToScreen(txt_bcost3.Location).Y + 180);
            txt_bcost3.Focus();
            txt_bcost3.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_Btime4_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_Btime4.Location).X + 65, PointToScreen(txt_Btime4.Location).Y + 180);
            txt_Btime4.Focus();
            txt_Btime4.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_bcost4_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_bcost4.Location).X + 65, PointToScreen(txt_bcost4.Location).Y + 180);
            txt_bcost4.Focus();
            txt_bcost4.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_cBtime_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_cBtime.Location).X + 65, PointToScreen(txt_cBtime.Location).Y + 180);
            txt_cBtime.Focus();
            txt_cBtime.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_cbcost_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_cbcost.Location).X + 65, PointToScreen(txt_cbcost.Location).Y + 180);
            txt_cbcost.Focus();
            txt_cbcost.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_stime1_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_stime1.Location).X+700, PointToScreen(txt_stime1.Location).Y + 180);
            txt_stime1.Focus();
            txt_stime1.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_scost1_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_scost1.Location).X + 500, PointToScreen(txt_scost1.Location).Y + 180);
            txt_scost1.Focus();
            txt_scost1.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_stime2_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_stime2.Location).X + 700, PointToScreen(txt_stime2.Location).Y + 180);
            txt_stime2.Focus();
            txt_stime2.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_scost2_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_scost2.Location).X + 500, PointToScreen(txt_scost2.Location).Y + 180);
            txt_scost2.Focus();
            txt_scost2.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_stime3_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_stime3.Location).X + 700, PointToScreen(txt_stime3.Location).Y + 180);
            txt_stime3.Focus();
            txt_stime3.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_scost3_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_scost3.Location).X + 500, PointToScreen(txt_scost3.Location).Y + 180);
            txt_scost3.Focus();
            txt_scost3.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_stime4_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_stime4.Location).X + 700, PointToScreen(txt_stime4.Location).Y + 180);
            txt_stime4.Focus();
            txt_stime4.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_scost4_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_scost4.Location).X + 500, PointToScreen(txt_scost4.Location).Y + 180);
            txt_scost4.Focus();
            txt_scost4.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_cstime_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_cstime.Location).X + 700, PointToScreen(txt_cstime.Location).Y + 180);
            txt_cstime.Focus();
            txt_cstime.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_cscost_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_cscost.Location).X + 500, PointToScreen(txt_cscost.Location).Y + 180);
            txt_cscost.Focus();
            txt_cscost.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_mtime1_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_mtime1.Location).X + 300, PointToScreen(txt_mtime1.Location).Y + 100);
            txt_mtime1.Focus();
            txt_mtime1.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_mcost1_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_mcost1.Location).X + 65, PointToScreen(txt_mcost1.Location).Y + 100);
            txt_mcost1.Focus();
            txt_mcost1.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_mtime2_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_mtime2.Location).X + 65, PointToScreen(txt_mtime2.Location).Y + 100);
            txt_mtime2.Focus();
            txt_mtime2.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_mcost2_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_mcost2.Location).X + 65, PointToScreen(txt_mcost2.Location).Y + 100);
            txt_mcost2.Focus();
            txt_mcost2.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_mtime3_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_mtime3.Location).X + 65, PointToScreen(txt_mtime3.Location).Y + 100);
            txt_mtime3.Focus();
            txt_mtime3.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_mcost3_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_mcost3.Location).X + 65, PointToScreen(txt_mcost3.Location).Y + 100);
            txt_mcost3.Focus();
            txt_mcost3.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_mtime4_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_mtime4.Location).X + 65, PointToScreen(txt_mtime4.Location).Y + 100);
            txt_mtime4.Focus();
            txt_mtime4.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_mcost4_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_mcost4.Location).X + 65, PointToScreen(txt_mcost4.Location).Y + 100);
            txt_mcost4.Focus();
            txt_mcost4.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_cmtime_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_cmtime.Location).X + 65, PointToScreen(txt_cmtime.Location).Y + 100);
            txt_cmtime.Focus();
            txt_cmtime.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }

        private void txt_cmcost_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_cmcost.Location).X + 65, PointToScreen(txt_cmcost.Location).Y + 100);
            txt_cmcost.Focus();
            txt_cmcost.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }
    }
}
